package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Menu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuMapper {

    @Select("select * from t_menu")
    List<Menu> findAll();

    @Select("select * from t_menu,t_role_menu where id=menu_id and role_id=#{id} ")
    Menu findMenuById(Integer id);

    Page<Menu> findByCondition(String queryString);

    @Select("select * from t_menu where level=1")
    List<Menu> findLevel();
    @Select("select * from t_menu where id=#{id}")
    Menu findById(Integer id);

    @Select("select menu_Id from t_role_menu where role_Id=#{id}")
    List<Integer> findMenuByRoleId(Integer id);

    @Insert("insert into t_menu value(#{id},#{name},#{linkUrl},#{path},#{priority},#{icon},#{description},#{parentMenuId},#{level})")
    void add(Menu menu);

    @Delete("delete from t_menu where id=#{id}")
    void delete(Integer id);

    void edit(Menu menu);

}
